/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ep.persistence.entities;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Access;
import javax.persistence.AccessType;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Spyros
 */
@XmlRootElement
@XmlAccessorType(XmlAccessType.PROPERTY)
@Entity
@Table(name = "t006_prescription", catalog = "epresc", schema = "")
@NamedQueries({
    @NamedQuery(name = "T006Prescription.findAll", query = "SELECT t FROM T006Prescription t"),
    @NamedQuery(name = "T006Prescription.findById", query = "SELECT t FROM T006Prescription t WHERE t.id = :id"),
    @NamedQuery(name = "T006Prescription.findByChronic", query = "SELECT t FROM T006Prescription t WHERE t.chronic = :chronic"),
    @NamedQuery(name = "T006Prescription.findByBeginDate", query = "SELECT t FROM T006Prescription t WHERE t.beginDate = :beginDate"),
    @NamedQuery(name = "T006Prescription.findByEndDate", query = "SELECT t FROM T006Prescription t WHERE t.endDate = :endDate"),
    @NamedQuery(name = "T006Prescription.findByDiagnosisComments", query = "SELECT t FROM T006Prescription t WHERE t.diagnosisComments = :diagnosisComments"),
    @NamedQuery(name = "T006Prescription.findByPrescDate", query = "SELECT t FROM T006Prescription t WHERE t.prescDate = :prescDate")})
@Access(AccessType.FIELD)
public class T006Prescription implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Column(name = "chronic")
    private Boolean chronic = false;
    @Column(name = "begin_date")
    @Temporal(TemporalType.DATE)
    private Date beginDate;
    @Column(name = "end_date")
    @Temporal(TemporalType.DATE)
    private Date endDate;
    @Column(name = "diagnosis_comments")
    private String diagnosisComments;
    @Column(name = "presc_date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date prescDate;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "t006Prescription")
    private Collection<T008Dosage> t008DosageCollection;
    @JoinColumn(name = "t012_diagnosis_id", referencedColumnName = "id")
    @ManyToOne()
    private T012Diagnosis t012Diagnosis;
    @JoinColumn(name = "t005_patient_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private T005Patient t005Patient;
    @JoinColumn(name = "t003_pharmacist_id", referencedColumnName = "id")
    @ManyToOne(fetch= FetchType.LAZY)
    private T003Pharmacist t003Pharmacist;
    @JoinColumn(name = "t002_doctor_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private T002Doctor t002Doctor;

    public T006Prescription() {
    }

    public T006Prescription(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Boolean getChronic() {
        return chronic;
    }

    public void setChronic(Boolean chronic) {
        this.chronic = chronic;
    }

    public Date getBeginDate() {
        return beginDate;
    }

    public void setBeginDate(Date beginDate) {
        this.beginDate = beginDate;
    }

    public Date getEndDate() {
        return endDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    public String getDiagnosisComments() {
        return diagnosisComments;
    }

    public void setDiagnosisComments(String diagnosisComments) {
        this.diagnosisComments = diagnosisComments;
    }

    public Date getPrescDate() {
        return prescDate;
    }

    public void setPrescDate(Date prescDate) {
        this.prescDate = prescDate;
    }

    public Collection<T008Dosage> getT008DosageCollection() {
        return t008DosageCollection;
    }

    public void setT008DosageCollection(Collection<T008Dosage> t008DosageCollection) {
        this.t008DosageCollection = t008DosageCollection;
    }

//    @XmlTransient
    public T012Diagnosis getT012Diagnosis() {
        return t012Diagnosis;
    }

    public void setT012Diagnosis(T012Diagnosis t012Diagnosis) {
        this.t012Diagnosis = t012Diagnosis;
    }

    @XmlTransient
    public T005Patient getT005Patient() {
        return t005Patient;
    }

    public void setT005Patient(T005Patient t005Patient) {
        this.t005Patient = t005Patient;
    }

    @XmlTransient
    public T003Pharmacist getT003Pharmacist() {
        return t003Pharmacist;
    }

    public void setT003Pharmacist(T003Pharmacist t003Pharmacist) {
        this.t003Pharmacist = t003Pharmacist;
    }

    public T002Doctor getT002Doctor() {
        return t002Doctor;
    }

    public void setT002Doctor(T002Doctor t002Doctor) {
        this.t002Doctor = t002Doctor;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof T006Prescription)) {
            return false;
        }
        T006Prescription other = (T006Prescription) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "ep.persistence.entities.T006Prescription[id=" + id + "]";
    }
}
